<?php


namespace App\Services\Report;

use App\Common\ResponseCode;
use App\Common\Tools;
use App\Exceptions\BusinessException;
use App\Models\Base\Resource;
use App\Models\Role\Role;
use App\Models\Role\RoleResourceBind;
use App\Params\Backend\RoleListParam;
use App\Params\Backend\RoleUpdateMenuParam;
use App\Params\Backend\RoleUpdateParam;
use App\Params\Backend\RoleUpdateResourceParam;
use App\Repository\DashboardRepository;
use App\Repository\ResourceRepository;
use App\Repository\RoleRepository;
use App\Services\BaseService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

/**
 * 经营概况报表统计相关业务类
 *
 * @author WangBin
 * @date 2022-01-13
 * @package App\Http\Services
 */
class DashboardService extends BaseService
{
    /**
     * 创建统计报表记录
     *
     * @return int|mixed
     */
    public function create()
    {
        return DashboardRepository::getInstance()->save([
            'report_id' => Tools::nextId(),
            'report_time' => Tools::getDateTime(),
            'data' => [],
            'status' => 1
        ]);
    }

    /**
     * 更新报表数据
     *
     * @param array $data
     * @param int $reportId
     * @return int|mixed
     */
    public function update(array $data, int $reportId)
    {
        return DashboardRepository::getInstance()->save($data, $reportId);
    }

    /**
     * 查询运营看板数据
     *
     * @return mixed
     */
    public function getData()
    {
        return DashboardRepository::getInstance()->get();
    }
}
